﻿/*
{
"状态":1,
"名称":"修改-部门资料",
"作者":"陈泽椿",
"创建时间":"2018-06-30",
"功能":"修改-部门资料",
"log": [
	{"date":"06-01" , "dev" :"hzhh" , "content" : ""}
]
}
*/
declare @department_key int ,@department_id varchar(100), @department_name varchar(100)
declare @remarks varchar(100)

set @department_key = '{department_key}'
set @department_id = '{department_id}'
set @department_name ='{department_name}' 
set @remarks = '{remarks}'


--校验信息
if isnull(@department_id,'')=''
begin 
	RAISERROR ('SQL:不么部门id不允许为空', 16 ,1 ) ; 
	return 
end 


if isnull(@department_name,'')=''
begin 
	RAISERROR ('SQL:部门名称不允许为空', 16 ,1 ) ; 
	return 
end 


if EXISTS(SELECT * FROM b_department WHERE [department_key] <> @department_key and [department_id]=@department_id )
begin
	RAISERROR ('SQL:部门id已经存在', 16 ,1 ) ; 
	return 
end

update [dbo].[b_department] set
[department_id] = @department_id ,
[department_name] = @department_name ,
[remarks] = @remarks , 
[update_time] = getdate()
where [department_key] = @department_key